Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-ux

Package Overview
Dependencies
Maintainers
7
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-ux

cli IO utilities

  • 6.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
684K
decreased by-3.67%
Maintainers
7
Weekly downloads
 
Created

What is cli-ux?

The cli-ux npm package provides a set of utilities for building command-line interfaces (CLIs). It offers features such as progress bars, spinners, prompts, and table formatting to enhance the user experience of CLI applications.

What are cli-ux's main functionalities?

Progress Bar

This feature allows you to display a progress bar in the terminal. The code sample demonstrates how to create and update a progress bar that increments by 5% every 100 milliseconds until it reaches 100%.

const cli = require('cli-ux');

const progress = cli.progress({ format: 'progress [{bar}] {percentage}% | ETA: {eta}s' });
progress.start(100, 0);

let value = 0;
const interval = setInterval(() => {
  value += 5;
  progress.update(value);
  if (value >= 100) {
    clearInterval(interval);
    progress.stop();
  }
}, 100);

Spinner

This feature provides a spinner to indicate ongoing processes. The code sample shows how to start a spinner with a message and stop it after 3 seconds with a 'done' message.

const cli = require('cli-ux');

cli.action.start('Processing');
setTimeout(() => {
  cli.action.stop('done');
}, 3000);

Prompt

This feature allows you to prompt the user for input. The code sample demonstrates how to ask the user for their name and then greet them with the provided input.

const cli = require('cli-ux');

(async () => {
  const name = await cli.prompt('What is your name?');
  console.log(`Hello, ${name}!`);
})();

Table

This feature allows you to display data in a table format. The code sample shows how to create a table with two columns: 'name' and 'age', and display two rows of data.

const cli = require('cli-ux');

const data = [
  { name: 'John', age: 30 },
  { name: 'Jane', age: 25 }
];
cli.table(data, {
  name: {
    minWidth: 7
  },
  age: {
    header: 'Age'
  }
});

Other packages similar to cli-ux

Keywords

FAQs

Package last updated on 31 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc